package com.xuecheng.manage_course.controller;

import com.xuecheng.api.course.CourseControllerApi;
import com.xuecheng.framework.domain.cms.CmsSite;
import com.xuecheng.framework.domain.course.ext.Courseview;
import com.xuecheng.framework.domain.course.ext.TeachplanNode;
import com.xuecheng.framework.domain.course.response.CoursePublishResult;
import com.xuecheng.framework.model.response.ResponseResult;
import com.xuecheng.manage_course.service.CourseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/course")
public class CourseController implements CourseControllerApi {
    @Autowired
    CourseService courseService;

    @GetMapping("/teachplan/list/{courseId}")
    @Override
    public TeachplanNode findTeachPlanList(@PathVariable("courseId") String courseId) {
        return courseService.findTeachPlanList(courseId);
    }

    @Override
    @PostMapping("/coursepic/add")
    public ResponseResult addCoursePic(@RequestParam("courseId") String courseId, @RequestParam("pic")String pic) {
        System.out.println(courseId);
        return courseService.addCourseIdPic(courseId,pic);

    }
    @DeleteMapping("/coursepic/delete")
    @Override
    public ResponseResult deleteCoursePic(String courseid) {
        return courseService.deleteCoursePic(courseid);
    }
    //课程发布
    @Override
    @PostMapping("/publish/{id}")
    public CoursePublishResult publish(@PathVariable("id") String id) {
        //调用cms 一键发布接口
        return courseService.publish(id);
    }
    @PostMapping("preview/{id}")
    @Override
    public CoursePublishResult preview(@PathVariable("id") String id) {
        return courseService.preview(id);
    }
    //预览接口
    @Override
    @GetMapping("/courseview/{id}")
    public Courseview courseview(@PathVariable("id") String id) {
        return  courseService.getCourseview(id) ;
    }
}
